import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 余额变动记录信息 */
export interface UserBalanceRecord {
          id: number; // ID
          userId?: number; // 用户ID
          deptId?: number; // 部门ID
          title?: string; // 标题
          type?: boolean; // 类型（0支出 1收入）
          recordTime?: string | Dayjs; // 记录时间
          preBalance?: number; // 变动前余额
          amount?: number; // 变动金额
          postBalance?: number; // 变动后余额
          remark: string; // 备注
  }

// 余额变动记录 API
export const UserBalanceRecordApi = {
  // 查询余额变动记录分页
  getUserBalanceRecordPage: async (params: any) => {
    return await request.get({ url: `/business/user-balance-record/page`, params })
  },

  // 查询余额变动记录详情
  getUserBalanceRecord: async (id: number) => {
    return await request.get({ url: `/business/user-balance-record/get?id=` + id })
  },

  // 新增余额变动记录
  createUserBalanceRecord: async (data: UserBalanceRecord) => {
    return await request.post({ url: `/business/user-balance-record/create`, data })
  },

  // 修改余额变动记录
  updateUserBalanceRecord: async (data: UserBalanceRecord) => {
    return await request.put({ url: `/business/user-balance-record/update`, data })
  },

  // 删除余额变动记录
  deleteUserBalanceRecord: async (id: number) => {
    return await request.delete({ url: `/business/user-balance-record/delete?id=` + id })
  },

  /** 批量删除余额变动记录 */
  deleteUserBalanceRecordList: async (ids: number[]) => {
    return await request.delete({ url: `/business/user-balance-record/delete-list?ids=${ids.join(',')}` })
  },

  // 导出余额变动记录 Excel
  exportUserBalanceRecord: async (params) => {
    return await request.download({ url: `/business/user-balance-record/export-excel`, params })
  },
}